package com.example.dao;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.domain.Stu;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;

@SpringBootTest
public class StuDaoTestCase {

    @Autowired
    private StuDao stuDao;

    @Test
    void testGetByid() {
        System.out.println(stuDao.selectById(1));
    }

    @Test
    void testSave() {
        Stu stu = new Stu();
        stu.setName("网五月ssssss");
        stu.setPassword("35315");
        stu.setGender('男');
        stuDao.insert(stu);
    }

    @Test
    void testUdat() {
        Stu stu = new Stu();
        stu.setId(4);
        stu.setName("网五月asdf");
        stu.setPassword("35315");
        stu.setGender('男');
        stuDao.updateById(stu);
    }

    @Test
    void testdGtAll() {
        System.out.println(stuDao.selectList(null));
    }

    @Test
    void testdGtag() {
        IPage page = new Page(3,3);
        stuDao.selectPage(page,null);
        System.out.println(page.getCurrent());
        System.out.println(page.getSize());
        System.out.println(page.getTotal());
        System.out.println(page.getPages());
        System.out.println(page.getRecords());
    }

    @Test
    void testdGtBy() {
        QueryWrapper<Stu> qw = new QueryWrapper<>();
        qw.like("password","2");
        stuDao.selectList(qw);
    }

    @Test
    void testdGtBy1() {
        LambdaQueryWrapper<Stu> lqw = new LambdaQueryWrapper<Stu>();
        lqw.like(Stu::getPassword,"2");
        stuDao.selectList(lqw);
    }
}
